<!--#include file="inc/conn.asp" -->
<!--#include file="inc/Function.asp" -->
<!--#include file="inc/pageClass.asp"-->
<%

If request("Action") = "Del" Then
	Id = Trim(checkstr(request("Id")))
	set rs=conn.execute("Delete  from WEB_ where Id="&Id)
End If 


If request("Action") = "Add" Then
    user_id = Trim(request("Id"))
    user_mac = Trim(checkstr(request("Mac")))
    user_ip =Trim(request("Ip"))
    logoff =Trim(request("logoff"))

If user_id="" Or user_mac="" Or user_ip="" Then
	response.write "<script language=javascript>alert('失败,所有值均不允许空,请手动添加!');window.history.go(-1); </script>"

else
	If logoff="" Then logoff=0

		set rs=conn.execute("INSERT INTO [WEB_blacklist](user_id,user_mac,user_hard,user_ip,logoff,user_time) VALUES('"&user_id&"','"&user_mac&"','"&user_hard&"','"&user_ip&"',"&logoff&",getdate())")
				If user_ip="11" Then 
					response.write "{""msg"":""踢号成功，请等待5-30秒!"",""status"":""yes""}"
					response.end
				else
				response.write "<script language=javascript>alert('命令执行成功!');window.history.go(-1);</script>"
				End If
	End If
End If 

txtSearch = Trim(checkstr(request("txtSearch")))

	If txtSearch<>""  Then
		sqlstr =  " where user_id like '%"&txtSearch&"%' or user_mac like '%"&txtSearch&"%' or user_hard like '%"&txtSearch&"%' or user_ip like '%"&txtSearch&"%'"
	End If

  sql="select *  from WEB_blacklist  "&sqlstr&" order by id desc"
  Set Rs = Server.CreateObject("ADODB.Recordset")
  Rs.Open sql,Conn,1,1
  Set page = New PageClass
    page.rs=Rs					'直接传递rs对象，传递成功后会自动关闭。如需要开启，请注释掉分页类的第87行val.Close。
    page.PageSize=Mypagesize					'分页大小
    page.setCount=-1					'可选。设置数据总数。0：使用RecordCount，-1：使用Count（默认），其他正数：指定的数据总数。
    page.PageID="p"					'Request.QueryString中分页参数字符串

strtitle=ServerName&"-黑名单管理"
Call  head(strtitle)
If browser()="pc" Then Call  LeftMenu()
%>
			
  <!-- 右侧主体开始 -->
  <div class="page-content">
<%Call  mnav()%>	
<div class="weadmin-body">



 <div class="layui-card" style="1margin-bottom:-10px;1margin-top:-10px">
<div class="layui-card-body">
<table width="99%" cellpadding="2" cellspacing="0">
  <tr>
    <td width="70%">

            <form class="layui-form layui-col-space5" action="black_list.asp" method="get">
              <div class="layui-inline layui-show-xs-block">
                <input name="ID" type="text" id="ID" value="账号" size="15" autocomplete="off" class="layui-input" onClick="select()"></div>
              <div class="layui-inline layui-show-xs-block">
                <input name="Mac" type="text" id="Mac" value="MAC" size="15" autocomplete="off" class="layui-input"  onClick="select()"></div>
              <div class="layui-inline layui-show-xs-block">
                <input name="HD" type="text" id="HD" value="HD" size="15" autocomplete="off" class="layui-input"  onClick="select()"></div>
              <div class="layui-inline layui-show-xs-block">
                <input name="Ip" type="text" id="Ip" value="IP地址" size="15" autocomplete="off" class="layui-input"  onClick="select()"></div>
              <input name="Action" type="hidden" id="Action" value="Add">
			  
			  <div class="layui-inline layui-show-xs-block" style="width:80px">
                  <select name="logoff" id="logoff">
                    <option value="0">屏蔽</option>
                    <option value="1">踢人</option>
                    <option value="2">惩罚</option></select>
                </div>

              <div class="layui-inline layui-show-xs-block">
                <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="sreach">
                  <i class="layui-icon">&#xe615;</i>添加黑名单</button></div>
            </form>
		</td>
    <td>
	<div style="float: right;">
<form  class="layui-form layui-col-space5" action="black_list.asp" method="post" name="form1">
                <div class="layui-inline layui-show-xs-block">
                  <input type="text" name="txtSearch" placeholder="请输入关键字" autocomplete="off" class="layui-input"></div>
                <div class="layui-inline layui-show-xs-block">
                  <input type="checkbox" name="SearchType" title="精确" value="1">
                  <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="sreach">
                    <i class="layui-icon">&#xe615;</i>搜索</button></div>
              </form>	</div>
                        </div>
	</td>
  </tr>
</table>

                        </div>
                    </div>

          <div class="layui-card-body layui-table-body layui-table-main" style="margin-top:-13px">
            <table class="layui-table layui-form">
              <thead>
                <tr>
                  <th height="35">ID</th>
                  <th>用户名</th>
                  <th>MAC地址</th>
                  <th>IP地址</th>
				  <th>发生时间</th>
                  <th>类型</th>
                  <th>删除</th></tr>
              </thead>
              <tbody>
                    <%
									  If page.eof Or page.bof Then 
									 response.write "<TR><TD>没有找到任何记录...</TD></TR>"
									 Else
										
									 Do While Not page.EOF
									 %>
                  <tr>
                    <td style="width: 20px; height:30px">
                      <%=page( "id")%></td>
                    <td>
                      <a href="User_List.asp?txtSearch=<%=page("user_id")%>">
                        <%=page( "user_id")%></a>
                    </td>
                    <td>
                      <a href="Black_List.asp?txtSearch=<%=page("user_mac")%>">
                        <%=page( "user_mac")%></a>
                    </td>
                    <td>
                      <a href="black_list.asp?txtSearch=<%=page("user_ip")%>">
                        <%=page( "user_ip")%></a>
                    </td>
					<td>                      
                        <%=page( "user_time")%>
                    </td>
                    <td>
                      <% If page( "logoff")=1 Then 
					  response.write "临时下线" 
					  ElseIf page( "logoff")=2 Then 
					  response.write "破坏" 
					  Else 
					  response.write "屏蔽" 
					  End If 
					  %>
					  </td>
                    <td height=30>
                      <%
					  response.write "<a href=black_list.asp?Action=Del&ID="&page( "Id")& "><FONT COLOR=""#CC0000""><b>删除</b></FONT></a>"
					  %>
					  </td>
                  </tr>
                  <%
				  page.MoveNext
				  Loop
				  End If 
				  %>
				  </tbody>
            </table>
          </div>
  <div class="page">
								<%
								If browser()="pc" Then
									Response.write page.Control(10,"{Ctrl} {State}")
								Else
									Response.write page.Control(5,"{Ctrl} {State}")
								End If
								 Set Rs=Nothing
								Set page=Nothing 
								conn.Close
								Set conn=Nothing 
								%>
                        </div>

		</div>
  </div>
	<%Call  footer%>
	<div id="LAY_democodejs">
    <script>layui.use(['laydate', 'form'],
      function() {
        var laydate = layui.laydate;
        var form = layui.form;

        // 监听全选
        form.on('checkbox(checkall)',
        function(data) {

          if (data.elem.checked) {
            $('tbody input').prop('checked', true);
          } else {
            $('tbody input').prop('checked', false);
          }
          form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });

      });

      /*用户-删除*/
      function member_del(obj, id) {
        layer.confirm('确认要删除吗？',
        function(index) {
          //发异步删除数据
          $(obj).parents("tr").remove();
          layer.msg('已删除!', {
            icon: 1,
            time: 1000
          });
        });
      }

      function delAll(argument) {
        var ids = [];

        // 获取选中的id 
        $('tbody input').each(function(index, el) {
          if ($(this).prop('checked')) {
            ids.push($(this).val())
          }
        });

        layer.confirm('确认要删除吗？' + ids.toString(),
        function(index) {
          //捉到所有被选中的，发异步进行删除
          layer.msg('删除成功', {
            icon: 1
          });
          $(".layui-form-checked").not('.header').parents('tr').remove();
        });
      }</script>
</body>
</html>